<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>设置配置——配置管理——鑫四合珠宝管理后台</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="huyuzhu">
<!-- Le styles -->
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/css/base.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.placeholder.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#addBtn").click(function(){
		var token = $("#token").html();
		if(token!=""){
			$("#ErrorMsg").html("新增加的配置项尚未提交,请先提交!");
			return;
		}
		$("#token").html("token");
    	var _len = $("#configAttrList tr").length; 
    	_len = _len+1;
    	$("#configAttrList").append("<tr id="+_len+">"
                        +"<td>"+_len+"</td>"                              
                        +"<td><input type='text' name='configAttrVO.attrName' id='attrName' /></td>"
                        +"<td><input type='text' name='configAttrVO.remark' id='remark' /></td>"
                        +"<td><a href=\'#\' id=\'addAttrLink\'>提交</a></td>"
                    +"</tr>");            
	});
	$("#addAttrLink").live("click",function(){
		var attrName = $.trim($("#attrName").val());
		if(attrName==""){
			$("#ErrorMsg").html("配置内容不能为空!");
			return false;
		}
		if(attrName.length>40){
			$("#ErrorMsg").html("配置内容不能超过20个汉字!");
			return false;
		}
		$("#addAttr").submit();        
	});
});

function deleteConfig(attrid){
	if(confirm("确认是否要删除?")){
		$("#attrid").attr("value",attrid);
		$("#deleteAttr").submit();
	}
}
</script>
</head>
<body>
<!-- 头部 -->
<s:include value="../header.jsp"/>
<!-- 主内容区开始 -->
<div class="conBox clearfix">
  <s:include value="menu.jsp">
  	<s:param name="menuIndex" value="6"/>
  </s:include>
  <div id="token" class="hide"></div>
  <div class="mainBox">
    <h1>设置配置</h1>
    <div class="ncBox">
      <table class="table table-bordered">
        <tr>
          <td class="garybg">类型名称：</td>
          <td><s:property value="configurationVO.configTypeName"/></td>
        </tr>
        <tr>
          <td class="garybg">种类数量：</td>
          <td><s:property value="configCount"/></td>
        </tr>
      </table>
      <div class="m_btnBox">
        <a href="#" id="addBtn" class="btn"><i class="icon-plus-sign"></i>新增配置</a>
        <span id="ErrorMsg" class="help-inline tred"></span>
      </div>
      <s:form id="deleteAttr" action="doDeleteAttr">
      	<input type="hidden" name="configAttrVO.configid" value='<s:property value="configurationVO.configid"/>'/>
      	<input type="hidden" id="attrid" name="configAttrVO.attrid"/>
      </s:form>
      <s:form id="addAttr" action="addingAttr">
      <input type="hidden" name="configAttrVO.configid" value='<s:property value="configurationVO.configid"/>'/>
      <table class="table table-bordered table-hover">
        <thead>
        <tr>
          <th>序号</th>
          <th>配置值</th>
          <th>扩展值</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody id="configAttrList">
        <s:iterator value="configAttrList" status="st">
        <tr>
          <td><s:property value="#st.index+1"/></td>
          <td><s:property value="attrName"/></td>
          <td><s:property value="remark"/></td>
          <td> <s:if test="canDelete==0"> <a href="#" onclick="deleteConfig(<s:property value='attrid'/>)">删除</a></s:if><s:else>保留</s:else></td>
        </tr>
        </s:iterator>
        </tbody>
      </table>
      </s:form>
    </div>
  </div>
</div>
<!-- 主内容区结束 --> 
<!-- 尾部 -->
<s:include value="../bottom.jsp"/>
</body>
</html>